package com.yang.refactor.unit_testing;

/**
 * @Description: 单元测试断言类
 * @Author: 杨 强
 * @CreateTime: 2022-10-14 11:20
 */
public class Assert {

    /**
     * @description: 断言
     * @param: expectedValue 执行结果
     * @param: actualValue 预期结果
     * @return: void
     * @author: 杨 强
     * @createTime: 2022/10/14 11:22
     **/
    public static void assertEquals(Integer expectedValue, Integer actualValue) {
        if (actualValue != expectedValue) {
            String message = String.format("Test failed, expected: %d, actual: %d.", expectedValue, actualValue);
            System.out.println(message);
        }
        else {
            System.out.println("Test succeeded.");
        }
    }

    /**
     * @description: 判断是否为null, 为null就是true
     * @param: actualValue 实际值
     * @return: boolean true:为空, false:不为空
     * @author: 杨 强
     * @createTime: 2022/10/14 11:22
     **/
    public static boolean assertNull(Integer actualValue) {
        boolean isNull = actualValue == null;
        if (isNull) {
            System.out.println("Test succeeded.");
        } else {
            System.out.println("Test failed, the value is not null:" + actualValue);
        }
        return isNull;
    }
}
